import React, { Fragment, Component } from "react";
import { Text, View, FlatList,Image,Dimensions } from "react-native";
import HttpUtil from "../../Utils/utils/HttpUtils";
var { height, width } = Dimensions.get("window");
//import console = require("console");
class Like extends Component {
  constructor() {
    super();
    this.state = {
      data: []
    };
  }
  componentDidMount() {
    HttpUtil.get("http://192.168.1.9:8080/native/like.json").then((res) => {
        console.log(res)
      this.setState({
        data: res.data
      });
    });
  }
  renderItems(item) {
      console.log(item)
    return (
      <View
        style={{
          flexDirection: "row",
          alignItems: "center",
          backgroundColor:'white'
        }}
      >
        <Image source={{ uri: item.item.url }} style={{width:0.5*width,height:100,resizeMode:'contain'}}/>
        <Text>{item.item.name}</Text>
      </View>
    );
  }
  render() {
    return (
      <Fragment>
        <FlatList
          data={this.state.data}
          renderItem={
            this.renderItems.bind(this)
          }
        />
      </Fragment>
    );
  }
}
export default Like;
